import java.util.Scanner;

public class MyDCTester {
    public static void main(String[] args) {

        String expression, again;

        Rational result = new Rational();

        try {
            Scanner in = new Scanner(System.in);

            do {
                MyDC evaluator = new MyDC();
                System.out.println("Enter a valid postfix expression: ");
                expression = in.nextLine();
                result = evaluator.evaluate(evaluator.trans(expression));
                System.out.println();
                int a = result.getNumerator();
                int b = result.getDenominator();
                if (b == 1) {
                    System.out.println("result=" + a);
                } else {
                    System.out.println("result=" + a + "/" + b);
                }
                System.out.print("Evaluate another expression [Y/N]? ");
                again = in.nextLine();
                System.out.println();
            }
            while (again.equalsIgnoreCase("y"));
        } catch (Exception IOException) {
            System.out.println("Input exception reported");
        }
    }

}
